package com.stox.client.ui.javafx.chartingy.model.node;

import com.stox.client.ui.javafx.chartingy.model.plot.Plot;

import javafx.scene.Group;
import javafx.scene.paint.Color;

public abstract class ChartingNode<T, V> extends Group {

	public ChartingNode() {
		setManaged(false);
		setAutoSizeChildren(false);
	}
	
	@Override
	protected void layoutChildren() {
		// No op
	}
	
	public abstract Color getColor();
	
	public abstract Plot<T,V> getPlot();
	
	protected double getDisplayPosition(double value) {
		Plot<?, ?> plot = getPlot();
		if (plot.isPrimary() || plot.chartingView().isMaintainRatio()) {
			return plot.getChart().getValueAxis().getDisplayPosition(value);
		} else {
			double min = plot.getMin();
			double max = plot.getMax();
			return (max - value) * plot.getChart().getValueAxis().getHeight() / (max - min);
		}
	}
	
}
